home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 2 / LSD and 17bit Compendium Deluxe - Volume II.iso / a / prog / cprog / metre.lha / ytab.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-07  |  64.0 KB  |  2,244 lines

  1. /* c:\mks\bin\yacc -d gram.y */
  2. #define TK_IDENTIFIER    257
  3. #define TK_CONSTANT    258
  4. #define TK_STRING_LITERAL    259
  5. #define TK_SIZEOF    260
  6. #define TK_PTR_OP    261
  7. #define TK_INC_OP    262
  8. #define TK_DEC_OP    263
  9. #define TK_LEFT_OP    264
  10. #define TK_RIGHT_OP    265
  11. #define TK_LE_OP    266
  12. #define TK_GE_OP    267
  13. #define TK_EQ_OP    268
  14. #define TK_NE_OP    269
  15. #define TK_AND_OP    270
  16. #define TK_OR_OP    271
  17. #define TK_MUL_ASSIGN    272
  18. #define TK_DIV_ASSIGN    273
  19. #define TK_MOD_ASSIGN    274
  20. #define TK_ADD_ASSIGN    275
  21. #define TK_SUB_ASSIGN    276
  22. #define TK_LEFT_ASSIGN    277
  23. #define TK_RIGHT_ASSIGN    278
  24. #define TK_AND_ASSIGN    279
  25. #define TK_XOR_ASSIGN    280
  26. #define TK_OR_ASSIGN    281
  27. #define TK_TYPE_NAME    282
  28. #define TK_TYPEDEF    283
  29. #define TK_EXTERN    284
  30. #define TK_STATIC    285
  31. #define TK_AUTO    286
  32. #define TK_REGISTER    287
  33. #define TK_CHAR    288
  34. #define TK_SHORT    289
  35. #define TK_INT    290
  36. #define TK_LONG    291
  37. #define TK_SIGNED    292
  38. #define TK_UNSIGNED    293
  39. #define TK_FLOAT    294
  40. #define TK_DOUBLE    295
  41. #define TK_CONST    296
  42. #define TK_VOLATILE    297
  43. #define TK_VOID    298
  44. #define TK_STRUCT    299
  45. #define TK_UNION    300
  46. #define TK_ENUM    301
  47. #define TK_ELIPSIS    302
  48. #define TK_RANGE    303
  49. #define TK_CASE    304
  50. #define TK_DEFAULT    305
  51. #define TK_IF    306
  52. #define TK_ELSE    307
  53. #define TK_SWITCH    308
  54. #define TK_WHILE    309
  55. #define TK_DO    310
  56. #define TK_FOR    311
  57. #define TK_GOTO    312
  58. #define TK_CONTINUE    313
  59. #define TK_BREAK    314
  60. #define TK_RETURN    315
  61. #define THEN    316
  62. extern int yychar, yyerrflag;
  63. #ifndef YYSTYPE
  64. #define YYSTYPE int
  65. #endif
  66. extern YYSTYPE yyval;
  67. extern YYSTYPE yylval;
  68. #line 708 "gram.y"
  69. /*************************************************************
  70.    Copyright (c) 1993,1994 by Paul Long  All rights reserved.
  71. **************************************************************/
  72.  
  73. #include <stdio.h>
  74. #include <limits.h>
  75. #include <stdarg.h>
  76. #include "metreint.h"
  77.  
  78. /* External variables. */
  79.  
  80. /*
  81.    Metre maintains statistics in the int_* structures, e.g., int_prj.  The
  82.    structures with the unadorned names, e.g., prj, are used to communicate with
  83.    the rules.  They are zero-filled except when a trigger is being fired.  At
  84.    that time, the contents of the corresponding int_* structure is copied
  85.    to it, the rules() function is called, and then the structure is zero-filed
  86.    again.
  87. */
  88. PRJ prj, int_prj;    /* Project. */
  89. MOD mod, int_mod;    /* Module. */
  90. FCN fcn;             /* Function. */
  91. static FCN int_fcn;
  92. STM stm;             /* Statement. */
  93. static STM int_stm;
  94. LIN lin, int_lin;    /* Line. */
  95. LEX lex, int_lex;    /* Lexeme. */
  96.  
  97. /*
  98.    Which command-line argument (argv) at which to start looking for the next
  99.    file name to process and original file name, respectively.
  100. */
  101. unsigned next_cmd_line_file;
  102. unsigned next_cmd_line_file_orig_n;
  103.  
  104. /* Number of decision points and functions in module (file). */
  105. unsigned mod_decisions;
  106. unsigned mod_functions;
  107.  
  108. /*
  109.    Indicates whether we are looking for a tag.  Parser writes it, lexer reads
  110.    it.  Since tags are in a separate name space from other identifiers, this
  111.    helps the lexer determine whether a lexeme is an identifier or a type name.
  112. */
  113. BOOLEAN looking_for_tag;
  114.  
  115. /*
  116.    Indicates whether we are within a function definition.  Used to determine
  117.    whether to use the last identifier as the function name.
  118. */
  119. BOOLEAN is_within_function;
  120.  
  121. /*
  122.    Name of current input file and name of original file, if specified on
  123.    command line with the substitute-file-name option.  If substitute not
  124.    provided, input_file_orig_name points to the same name as input_file.
  125. */
  126. char *input_file;
  127. char *input_file_orig_name;
  128.  
  129. /* Where all output is written. */
  130. FILE *out_fp;
  131.  
  132. /* Global versions of main's argc and argv. */
  133. int cmd_line_argc;
  134. char **cmd_line_argv;
  135.  
  136. /*
  137.    Block within which typedef type names are held in the typedef symbol-table.
  138. */
  139. typedef struct typedef_sym_blk {
  140.    struct typedef_sym_blk *next;          /* Next block. */
  141.    unsigned total;                        /* Total in this block. */
  142.    char *id[TYPEDEF_SYMBOLS_PER_BLOCK]; /* Array of pointers to type names. */
  143. } TYPEDEF_SYM_BLK;
  144.  
  145. /*
  146.    Head of the typedef symbol-table.  NOTE: This is the only symbol table in
  147.    Metre, and it is used just to hold typedef type names, not all symbols.
  148. */
  149. TYPEDEF_SYM_BLK *typedef_sym_tbl_head = NULL;
  150.  
  151.  
  152. /* Static variables. */
  153.  
  154. /* Control depth--current number of nested control structures. */
  155. static unsigned depth;
  156.  
  157. /* Used to determine how many statements are on a line. */
  158. static unsigned previous_statements_line_number;
  159.  
  160. /* Number of decision points in function. */
  161. static unsigned fcn_decisions;
  162.  
  163. /*
  164.    Metre maintains the number of statements appearing on a line.
  165.    The is_if and is_else BOOLEANs are used principally to relax the
  166.    criteria for what constitutes a statement.  For example, "else if,"
  167.    is not considered two statements because this is a common idiom.
  168. */
  169. static BOOLEAN is_else, is_if;
  170.  
  171. /*
  172.    is_typedef indicates whether we are parsing a typedef.  Since typedefs
  173.    cannot be nested, it's okay that this is just a BOOLEAN.  This is used to
  174.    find the type name of a typedef so that it can be added to the typedef
  175.    symbol table.  If the type name is subsequently encountered by the lexer,
  176.    the lexer returns a token for a type name rather than for an identifier.
  177.    This is the ugly part of C that cannot practically be expressed by a YACC
  178.    grammar specification.
  179. */
  180. static BOOLEAN is_typedef;
  181.  
  182. /*
  183.    nested_decl_specs is used to distinguish the type name of the root-level
  184.    declaration in a typedef from other identifiers in the typedef.
  185. */
  186. static unsigned nested_decl_specs;
  187.  
  188. /*
  189.    Whether the last statement was a case label.  Used to consider adjacent
  190.    case labels as one decision point.  The transition from is_case_label==TRUE
  191.    to is_case_label==FALSE is a decision point, instead of each case label
  192.    being a decision point.  Adjacent case labels are considered one decision
  193.    point because this is analogous to an if statement with or logical
  194.    operators, ||.  For example,
  195.  
  196.       switch (expr) {
  197.       case 5:
  198.       case 10:
  199.          a;
  200.       }
  201.  
  202.    is, in this regard, analogous to
  203.  
  204.       if (expr == 5 || expr == 10)
  205.          a;
  206.  
  207.    I did not want to bias the metric against the switch statement.
  208. */
  209. static BOOLEAN is_case_label;
  210.  
  211. static IDENTIFIER function_name;
  212. static IDENTIFIER last_identifier;
  213.  
  214. /* Static function declarations. */
  215.  
  216. static void fire_fcn(void);
  217. static void fire_stm(void);
  218. static void print_exception(int, char *, char *, va_list);
  219. static void typedef_symbol_table_add(char *);
  220. static void case_label(void);
  221. static void not_case_label(void);
  222. static void check_starting_options(void);
  223. static void print_banner(void);
  224. static void print_help(void);
  225. static void stat_func_begin(void);
  226. static void stat_func_end(void);
  227. static void check_multiple_statements(void);
  228. static void int_fatal(int, char *, ...);
  229. static void int_warn(int, char *, ...);
  230.  
  231.  
  232. /* Functions. */
  233.  
  234. main(int argc, char *argv[])
  235. {
  236.    print_banner();
  237.  
  238.    /* Save so that the argument list may be accessed globally. */
  239.    cmd_line_argv = argv;
  240.    cmd_line_argc = argc;
  241.  
  242.    /* Get command-line options that affect Metre at the start. */
  243.    check_starting_options();
  244.  
  245.    /* Initialize YACC and Lex. */
  246.    init_yacc();
  247.    init_lex();
  248.  
  249.    /*
  250.       Look for the first input file and first original name of that input file.
  251.    */
  252.    next_cmd_line_file = 0;
  253.    next_cmd_line_file_orig_n = 0;
  254.    if ((input_file = get_next_input_file(&next_cmd_line_file)) != NULL)
  255.       if ((yyin = fopen(input_file, "r")) != NULL)
  256.       {
  257.          input_file_orig_name =
  258.                get_next_input_file_orig_name(&next_cmd_line_file_orig_n);
  259.          /* If no original name given, use the actual as the original, also. */
  260.          if (input_file_orig_name == NULL)
  261.             input_file_orig_name = input_file;
  262.  
  263.          /* Fire the beginning-of-project trigger. */
  264.          ZERO(int_prj);
  265.          int_prj.begin = TRUE;
  266.          fire_prj();
  267.          int_prj.begin = FALSE;
  268.  
  269.          /* Fire the beginning-of-module trigger. */
  270.          ZERO(int_mod);
  271.          int_mod.begin = TRUE;
  272.          fire_mod();
  273.          int_mod.begin = FALSE;
  274.  
  275.          /*
  276.             Call the YACC-generated parser to wade through the input file(s).
  277.             When all done, close the last input file.  yywrap() could have
  278.             opened any number of subsequent input files.
  279.          */
  280.          yyparse();
  281.          fclose(yyin);
  282.       }
  283.       else
  284.          int_warn(W_CANNOT_OPEN_FILE, input_file);
  285.    else
  286.       /* Since no input file specified on command line, print Metre's help. */
  287.       print_help();
  288.  
  289. /* VMS has different ideas about what constitutes a successful return value. */
  290. #ifdef VAX
  291.    return 1;
  292. #else
  293.    return 0;
  294. #endif
  295. }
  296.  
  297. /* Common exception-handling function. */
  298. static void print_exception(int n, char *severity_str, char *format, va_list ap)
  299. {
  300.    fflush(out_fp);
  301.  
  302.    /*
  303.       Display input line if supposed to, then display line with marker
  304.       character in it if appropriate.
  305.    */
  306.    if (mod_name() != NULL && strlen(mod_name()) > 0)
  307.    {
  308.       if (!int_mod.end && !int_fcn.end)
  309.       {
  310.          if (!display_input && READ_LINE)
  311.             fputs(line(), out_fp);
  312.  
  313.          if (!int_lin.end && READ_LINE)
  314.             fputs(marker(), out_fp);
  315.       }
  316.    }
  317.  
  318.    /*
  319.       Display module name and line number if a module name has been established.
  320.       If one hasn't, the error must not relate to a location in the input file.
  321.    */
  322.    if (mod_name() != NULL && strlen(mod_name()) > 0)
  323.       fprintf(out_fp, "%s(%u): ", mod_name(), yylineno);
  324.    fprintf(out_fp, "%s%04u: ", severity_str, n);
  325.  
  326.    vfprintf(out_fp, format, ap);
  327.    fputc('\n', out_fp);
  328. }
  329.  
  330. /* Print message for internal fatal error. */
  331. static void int_fatal(int n, char *format, ...)
  332. {
  333.    va_list ap;
  334.  
  335.    va_start(ap, format);
  336.  
  337.    print_exception(n, "Fatal Error ME", format, ap);
  338.  
  339.    exit(1);
  340. }
  341.  
  342. /* Print message for fatal error that occured in the rules() function. */
  343. void fatal(int n, char *format, ...)
  344. {
  345.    va_list ap;
  346.  
  347.    va_start(ap, format);
  348.  
  349.    print_exception(n, "Fatal Error E", format, ap);
  350.  
  351.    exit(1);
  352. }
  353.  
  354. /* Print message for internal warning. */
  355. static void int_warn(int n, char *format, ...)
  356. {
  357.    va_list ap;
  358.  
  359.    va_start(ap, format);
  360.  
  361.    print_exception(n, "Warning MW", format, ap);
  362. }
  363.  
  364. /* Print message for warning that occured in the rules() function. */
  365. void warn(int n, char *format, ...)
  366. {
  367.    va_list ap;
  368.  
  369.    va_start(ap, format);
  370.  
  371.    print_exception(n, "Warning W", format, ap);
  372. }
  373.  
  374. /* Function called by YACC when it detects an error. */
  375. void yyerror(char *s)
  376. {
  377. #ifdef DEBUG_TYPEDEF
  378.    /* Used for debugging typedef processing. */
  379.    typedef_symbol_table_dump();
  380. #endif
  381.    int_fatal(0, "%s", s);
  382. }
  383.  
  384. /* Add type name to the typedef symbol table. */
  385. static void typedef_symbol_table_add(char *p_symbol)
  386. {
  387.    TYPEDEF_SYM_BLK *block;
  388.    char *str_buf = (char *)malloc(strlen(p_symbol) + 1);
  389.  
  390.    if (str_buf == NULL)
  391.       int_fatal(E_NO_HEAP);
  392.  
  393.    /* Make copy of argument. */
  394.    strcpy(str_buf, p_symbol);
  395.  
  396.    /* Is symbol table empty? */
  397.    if (typedef_sym_tbl_head == NULL)
  398.    {
  399.       /* Allocate first block and make the head of the table list. */
  400.       typedef_sym_tbl_head = block = (TYPEDEF_SYM_BLK *)malloc(sizeof *block);
  401.       if (block == NULL)
  402.          int_fatal(E_NO_HEAP);
  403.  
  404.       block->total = 0;
  405.       block->next = NULL;
  406.    }
  407.    else
  408.    {
  409.       TYPEDEF_SYM_BLK *prev_block;
  410.  
  411.       /* Find first block in symbol-table list that isn't full. */
  412.       for (prev_block = NULL, block = typedef_sym_tbl_head;
  413.             block != NULL && block->total == DIM_OF(block->id);
  414.             prev_block = block, block = block->next)
  415.          ;
  416.  
  417.       /* If all blocks are full, allocate a new one and append to list. */
  418.       if (block == NULL)
  419.       {
  420.          block = (TYPEDEF_SYM_BLK *)malloc(sizeof *block);
  421.          if (block == NULL)
  422.             int_fatal(E_NO_HEAP);
  423.  
  424.          block->total = 0;
  425.          block->next = NULL;
  426.          if (prev_block == NULL)
  427.             typedef_sym_tbl_head = block;
  428.          else
  429.             prev_block->next = block;
  430.       }
  431.    }
  432.  
  433.    /* Save pointer to the new type name in first empty slot of this block. */
  434.    block->id[block->total++] = str_buf;
  435. }
  436.  
  437. /* Return TRUE if symbol exists in the typedef symbol table. */
  438. BOOLEAN typedef_symbol_table_find(char *p_symbol)
  439. {
  440.    TYPEDEF_SYM_BLK *block;
  441.    BOOLEAN found = FALSE;
  442.  
  443.    /* Loop for each block of symbols. */
  444.    for (block = typedef_sym_tbl_head; block != NULL; block = block->next)
  445.    {
  446.       unsigned i;
  447.  
  448.       /* Loop for each symbol in this block. */
  449.       for (i = 0; i < block->total; ++i)
  450.          if (strcmp(block->id[i], p_symbol) == 0)
  451.             found = TRUE;
  452.    }
  453.  
  454.    return found;
  455. }
  456.  
  457. /*
  458.    Remove all symbols (and symbol blocks) from the symbol table--make the
  459.    table empty.
  460. */
  461. void typedef_symbol_table_flush(void)
  462. {
  463.    TYPEDEF_SYM_BLK *block;
  464.  
  465.    /* Loop for each block of symbols. */
  466.    for (block = typedef_sym_tbl_head; block != NULL; )
  467.    {
  468.       unsigned i;
  469.       TYPEDEF_SYM_BLK *temp_block;
  470.  
  471.       /* Loop for each symbol in this block. */
  472.       for (i = 0; i < block->total; ++i)
  473.          free(block->id[i]);              /* Free symbol. */
  474.  
  475.       temp_block = block->next;
  476.       free(block);                        /* Free block now that it's empty. */
  477.       block = temp_block;
  478.    }
  479.  
  480.    typedef_sym_tbl_head = NULL;
  481. }
  482.  
  483. #ifdef DEBUG_TYPEDEF
  484. /*
  485.    Display the contents of the typedef symbol table.  Used for debugging
  486.    typedef processing.
  487. */
  488. void typedef_symbol_table_dump(void)
  489. {
  490.    TYPEDEF_SYM_BLK *block;
  491.  
  492.    puts("typedef symbol table dump:");
  493.  
  494.    /* Loop for each block of symbols. */
  495.    for (block = typedef_sym_tbl_head; block != NULL; block = block->next)
  496.    {
  497.       unsigned i;
  498.  
  499.       /* Loop for each symbol in this block. */
  500.       for (i = 0; i < block->total; ++i)
  501.          puts(block->id[i]);
  502.    }
  503. }
  504. #endif
  505.  
  506. /* Record that the last statement was a case label. */
  507. static void case_label(void)
  508. {
  509.    is_case_label = TRUE;
  510. }
  511.  
  512. /*
  513.    Record that the last statement was not a case label.  If the previous
  514.    statement was a case label, increment the decision-point counter--this ends
  515.    a run of adjacent case labels which count as one decision point.
  516. */
  517. static void not_case_label(void)
  518. {
  519.    if (is_case_label)
  520.    {
  521.       is_case_label = FALSE;
  522.       ++fcn_decisions;        /* This is a decision point. */
  523.    }
  524. }
  525.  
  526. /* Initialize parser. */
  527. void init_yacc(void)
  528. {
  529.    /* Make the typedef symbol table empty. */
  530.    typedef_symbol_table_flush();
  531.  
  532.    /*
  533.       See the definition of each of these variables, above, for more
  534.       information.
  535.    */
  536.    is_typedef = FALSE;
  537.    nested_decl_specs = 0;
  538.    is_case_label = FALSE;
  539.  
  540.    function_name[0] = '\0';
  541.    last_identifier[0] = '\0';
  542.  
  543.    mod_decisions = 0;
  544.    mod_functions = 0;
  545.    is_else = is_if = FALSE;
  546.    looking_for_tag = FALSE;
  547.  
  548.    is_within_function = FALSE;
  549. }
  550.  
  551. /*
  552.    Returns TRUE if the indicated option character was specified on the
  553.    command line.  E.g., for -S, would return TRUE for option('S').
  554. */
  555. int option(char opt_char)
  556. {
  557.    char *opt_str = str_option(opt_char);
  558.  
  559.    return opt_str == NULL ? 0 : strlen(opt_str) == 0 ? 1 : atoi(opt_str);
  560. }
  561.  
  562. /*
  563.    Returns pointer to the part of an option following the "=".  E.g.,
  564.    for -Xabc=def, it would point to the "def" part.
  565. */
  566. char *str_option(char opt_char)
  567. {
  568.    unsigned i;
  569.  
  570.    for (i = 1; i < cmd_line_argc; ++i)
  571.       if (strchr(OPT_INTRO_CHARS, cmd_line_argv[i][0]) != NULL)
  572.          if (toupper(cmd_line_argv[i][1]) == toupper(opt_char))
  573.             break;
  574.  
  575.    return i < cmd_line_argc ? &cmd_line_argv[i][2] : NULL;
  576. }
  577.  
  578. /*
  579.    Return pointer to the name of the next input file in the argv array
  580.    starting with the argument that p_i points to.  An input file name is
  581.    distinguished from the command-line options by not starting with one of
  582.    characters in the OPT_INTRO_CHARS string.
  583.  
  584.    NOTE: argument 0 is the name of the command, not the first argument, per se.
  585. */
  586. char *get_next_input_file(unsigned *p_i)
  587. {
  588.    for (++*p_i; *p_i < cmd_line_argc &&
  589.          strchr(OPT_INTRO_CHARS, cmd_line_argv[*p_i][0]) != NULL; ++*p_i)
  590.       ;
  591.  
  592.    return *p_i < cmd_line_argc ? cmd_line_argv[*p_i] : NULL;
  593. }
  594.  
  595. /*
  596.    Return pointer to the original name of the next input file in the argv
  597.    array starting with the argument that p_i points to.  An original name is
  598.    specified as a command-line option.  That is how an original name is
  599.    distinguished from the name of an actual input file
  600.  
  601.    NOTE: argument 0 is the name of the command, not the first argument, per se.
  602. */
  603. char *get_next_input_file_orig_name(unsigned *p_i)
  604. {
  605.    for (++*p_i; *p_i < cmd_line_argc; ++*p_i)
  606.       if (strchr(OPT_INTRO_CHARS, cmd_line_argv[*p_i][0]) != NULL &&
  607.             toupper(cmd_line_argv[*p_i][1]) == SUBST_FILE_OPT_CHAR)
  608.          break;
  609.  
  610.    return *p_i < cmd_line_argc ? &cmd_line_argv[*p_i][2] : NULL;
  611. }
  612.  
  613. /* Returns pointer to current module (file) name. */
  614. char *mod_name(void)
  615. {
  616.    return input_file_orig_name;
  617. }
  618.  
  619. /* Process the command-line options that affect the start of Metre. */
  620. static void check_starting_options(void)
  621. {
  622.    static char *output_file_name;
  623.  
  624.    /* Interleave the input with the output? */
  625.    display_input = option(COPY_INPUT_OPT_CHAR);
  626.  
  627.    /*
  628.       Name of listing file to contain output.  This for those OS's that don't
  629.       support command-line redirection, e.g., VMS.
  630.    */
  631.    output_file_name = str_option(LISTING_OPT_CHAR);
  632.    if (output_file_name != NULL && strlen(output_file_name) > 0)
  633.    {
  634.       out_fp = fopen(output_file_name, "w");
  635.       if (out_fp == NULL)
  636.       {
  637.          out_fp = stdout;     /* Restore to previous, good output file. */
  638.          int_fatal(E_CANT_OPEN_LISTING_FILE);   /* Die. */
  639.       }
  640.    }
  641.    else
  642.       out_fp = stdout;
  643. }
  644.  
  645. /* Print name, version, and copyright notice. */
  646. static void print_banner(void)
  647. {
  648.    printf("METRE Version %s  ", metre_version);
  649.    puts("Copyright (c) 1993,1994 by Paul Long  All rights reserved.");
  650. }
  651.  
  652. /* Print Metre command-usage information. */
  653. static void print_help(void)
  654. {
  655.    puts("Syntax: METRE [ options ] file[s]   Option character in either case.  / or -");
  656.    puts("-Dxxx=[xxx] Define identifier     -Lxxx  Name of listing file (stdout)");
  657.    puts("-Sxxx       Substitute file name  -C     Copy input to output");
  658. }
  659.  
  660. /* Called at the beginning of a function definition. */
  661. static void stat_func_begin(void)
  662. {
  663.    /* Fire the beginning-of-function trigger. */
  664.    ZERO(int_fcn);
  665.    int_fcn.begin = TRUE;
  666.    fire_fcn();
  667.    int_fcn.begin = FALSE;
  668.  
  669.    /* Initialize variables relating to a function. */
  670.    depth = 0;
  671.    is_within_function = TRUE;
  672.    fcn_decisions = 0;
  673.    previous_statements_line_number = 0;
  674.  
  675.    /* Install starting counts.  Will replace with deltas at end-of-function. */
  676.    int_fcn.lines.white = int_mod.lines.white;
  677.    int_fcn.lines.com = int_mod.lines.com;
  678.    int_fcn.lines.exec = int_mod.lines.exec;
  679.    int_fcn.lines.total = yylineno;
  680. }
  681.  
  682. /* Called at the end of a function definition. */
  683. static void stat_func_end(void)
  684. {
  685.    /*
  686.       Replace initial counts with their deltas to arrive at totals for
  687.       the function.
  688.    */
  689.    int_fcn.lines.white = int_mod.lines.white - int_fcn.lines.white;
  690.    int_fcn.lines.com = int_mod.lines.com - int_fcn.lines.com;
  691.    int_fcn.lines.exec = int_mod.lines.exec - int_fcn.lines.exec;
  692.    int_fcn.lines.total = yylineno - int_fcn.lines.total;
  693.  
  694.    ++mod_functions;                 /* Increment function count. */
  695.  
  696.    /* Accumulate function decision count into module decision count. */
  697.    mod_decisions += fcn_decisions;
  698.  
  699.    /*
  700.       Install the rest of the function-related information into the function
  701.       structure and fire the end-of-function trigger.
  702.    */
  703.    int_fcn.decisions = fcn_decisions;
  704.    int_fcn.end = TRUE;
  705.    fire_fcn();
  706.    ZERO(int_fcn);
  707.  
  708.    /*
  709.       Clear variables that would otherwise indicate that we are still
  710.       parsing a function.
  711.    */
  712.    strcpy(function_name, "");
  713.    is_within_function = FALSE;
  714. }
  715.  
  716. /*
  717.    Returns pointer to current function name, or an empty string if not in a
  718.    function.
  719. */
  720. char *fcn_name(void)
  721. {
  722.    return function_name;
  723. }
  724.  
  725. /*
  726.    Increment the number of statements for the current line.  This function is
  727.    called whenever a statement is encountered.  If the current line number is
  728.    the same as when the last statement was encountered and if this is not the
  729.    special situation of "else if," the counter is incremented.
  730. */
  731. static void check_multiple_statements(void)
  732. {
  733.    if (previous_statements_line_number == yylineno)
  734.       if (is_else && is_if)
  735.          ;        /* do nothing */
  736.       else
  737.          ++int_lin.statements;
  738.    else
  739.       previous_statements_line_number = yylineno;
  740.  
  741.    is_else = is_if = FALSE;
  742. }
  743.  
  744.  
  745. /*
  746.    This is true for all of the fire_*() functions: Copy the internal structure
  747.    to the exported structure, allow the triggers to fire in the rules()
  748.    function, then zero-fill the exported structure so that unrelated rules
  749.    won't execute when other triggers are fired.
  750. */
  751.  
  752. void fire_prj(void)
  753. {
  754.    prj = int_prj;
  755.    rules();
  756.    ZERO(prj);
  757. }
  758.  
  759. void fire_mod(void)
  760. {
  761.    mod = int_mod;
  762.    rules();
  763.    ZERO(mod);
  764. }
  765.  
  766. static void fire_fcn(void)
  767. {
  768.    fcn = int_fcn;
  769.    rules();
  770.    ZERO(fcn);
  771. }
  772.  
  773. static void fire_stm(void)
  774. {
  775.    stm = int_stm;
  776.    rules();
  777.    ZERO(stm);
  778. }
  779.  
  780. void fire_lin(void)
  781. {
  782.    lin = int_lin;
  783.    rules();
  784.    ZERO(lin);
  785. }
  786.  
  787. void fire_lex(void)
  788. {
  789.    lex = int_lex;
  790.    rules();
  791.    ZERO(lex);
  792. }
  793. static short yydef[] = {
  794.      203,  205,   -1,  -11,  -21,  202,  204,  -25,  -31,  -35, 
  795.      -39,  211,  213,  215,  217,  219,  221,  224,  229,  232, 
  796.      235,  236,  237,  206,  -45,   79,   53,  208,  201,  200, 
  797.      199,  199,  193,  -49,  197,  198,  212,  214,  216,  218, 
  798.      220,  222,  223,  225,  226,  227,  228,  230,  231,  233, 
  799.      234,  198,  207,  196,  -53,  -57,  195
  800. };
  801. static short yyex[] = {
  802.      257,  209,   40,  209,   42,  209,   59,  209,   -1,    4, 
  803.      257,  210,   40,  210,   42,  210,   59,  210,   -1,    3, 
  804.        0,    0,   -1,    1,  257,   11,   41,    9,   -1,   10, 
  805.      123,    7,   -1,    8,  123,    5,   -1,    6,   44,  208, 
  806.       59,  208,   -1,   12,   59,  194,   -1,    1,   59,  194, 
  807.       -1,    1,   41,  194,   -1,    1,   41,  194,   -1,    1
  808. };
  809. static short yyact[] = {
  810.     -195,   -1, -197, -305, -231, -288, -289, -290, -291, -292, 
  811.     -293, -294, -295, -296, -297, -298, -299, -300, -301, -302, 
  812.     -229, -228, -226,  301,  300,  299,  298,  297,  296,  295, 
  813.      294,  293,  292,  291,  290,  289,  288,  287,  286,  285, 
  814.      284,  283,  282,  257,   42,   40,   -1, -305, -292, -293, 
  815.     -294, -295, -296, -297, -298, -299, -300, -301, -302, -229, 
  816.     -228, -226,  301,  300,  299,  298,  297,  296,  295,  294, 
  817.      293,  292,  291,  290,  289,  288,  282,   42, -195,   -1, 
  818.     -197,  257,   42,   40, -195, -197,  257,   40,   -8, -188, 
  819.       91,   40, -187, -197,  257,  123, -230, -197,  257,  123, 
  820.     -195,   -1, -235, -197,  257,   59,   42,   40, -182, -305, 
  821.     -231, -288, -289, -290, -291, -292, -293, -294, -295, -296, 
  822.     -297, -298, -299, -300, -301, -302, -229, -228, -226,  301, 
  823.      300,  299,  298,  297,  296,  295,  294,  293,  292,  291, 
  824.      290,  289,  288,  287,  286,  285,  284,  283,  282,  123, 
  825.     -319,   41, -262, -257, -172, -258, -259, -260, -320, -261, 
  826.     -197, -238, -240, -176, -173, -174,  263,  262,  260,  259, 
  827.      258,  257,  126,   93,   45,   43,   42,   40,   38,   33, 
  828.     -197,  257, -305, -231, -288, -289, -290, -291, -292, -293, 
  829.     -294, -295, -296, -297, -298, -299, -300, -301, -302, -229, 
  830.     -228, -226,  301,  300,  299,  298,  297,  296,  295,  294, 
  831.      293,  292,  291,  290,  289,  288,  287,  286,  285,  284, 
  832.      283,  282, -166,   61, -165, -234,   59,   44, -262, -257, 
  833.     -172, -258, -259, -260, -363, -182, -355, -261, -197, -238, 
  834.     -240, -176, -173, -174, -305, -231, -288, -289, -290, -291, 
  835.     -292, -293, -294, -295, -296, -297, -298, -299, -300, -301, 
  836.     -302, -229, -228, -226, -154, -155, -158, -159, -160, -206, 
  837.     -161, -162, -163, -164,  -25,  315,  314,  313,  312,  311, 
  838.      310,  309,  308,  306,  305,  304,  301,  300,  299,  298, 
  839.      297,  296,  295,  294,  293,  292,  291,  290,  289,  288, 
  840.      287,  286,  285,  284,  283,  282,  263,  262,  260,  259, 
  841.      258,  257,  126,  125,  123,   59,   45,   43,   42,   40, 
  842.       38,   33, -305, -292, -293, -294, -295, -296, -297, -298, 
  843.     -299, -300, -301, -302, -229, -228, -226,  301,  300,  299, 
  844.      298,  297,  296,  295,  294,  293,  292,  291,  290,  289, 
  845.      288,  282, -322,   41, -321,   93, -152, -151,  271,   63, 
  846.     -150,  270, -149,  124, -148,   94, -147,   38, -145, -146, 
  847.      269,  268, -141, -142, -143, -144,  267,  266,   62,   60, 
  848.     -139, -140,  265,  264, -137, -138,   45,   43, -136, -134, 
  849.     -135,   47,   42,   37, -262, -257, -133, -258, -259, -260, 
  850.     -261, -197, -238, -240, -176, -173, -174,  263,  262,  260, 
  851.      259,  258,  257,  126,   45,   43,   42,   40,   38,   33, 
  852.     -262, -257, -172, -258, -259, -260, -261, -197, -238, -240, 
  853.     -176, -173, -174,  263,  262,  260,  259,  258,  257,  126, 
  854.       45,   43,   42,   40,   38,   33, -262, -257, -132, -258, 
  855.     -259, -260, -261, -197, -238, -240, -176, -173, -174,  263, 
  856.      262,  260,  259,  258,  257,  126,   45,   43,   42,   40, 
  857.       38,   33, -129, -130, -128, -131, -248, -249,  263,  262, 
  858.      261,   91,   46,   40, -262, -257, -172, -258, -259, -260, 
  859.     -261, -197, -238, -240, -176, -173, -174, -305, -292, -293, 
  860.     -294, -295, -296, -297, -298, -299, -300, -301, -302, -229, 
  861.     -228, -226,  301,  300,  299,  298,  297,  296,  295,  294, 
  862.      293,  292,  291,  290,  289,  288,  282,  263,  262,  260, 
  863.      259,  258,  257,  126,   45,   43,   42,   40,   38,   33, 
  864.     -241,  259, -125,  123, -124,   61, -123, -227,  125,   44, 
  865.     -120,  123, -262, -257, -172, -258, -259, -260, -119, -261, 
  866.     -197, -238, -240, -176, -173, -174,  263,  262,  260,  259, 
  867.      258,  257,  126,  123,   45,   43,   42,   40,   38,   33, 
  868.     -368,   59, -367,   59,  -34,   40, -115,   40, -114,   40, 
  869.     -113,   40, -262, -257, -172, -258, -259, -260, -363, -182, 
  870.     -357, -261, -197, -238, -240, -176, -173, -174, -305, -231, 
  871.     -288, -289, -290, -291, -292, -293, -294, -295, -296, -297, 
  872.     -298, -299, -300, -301, -302, -229, -228, -226, -154, -155, 
  873.     -158, -159, -160, -206, -161, -162, -163, -164,  -25,  315, 
  874.      314,  313,  312,  311,  310,  309,  308,  306,  305,  304, 
  875.      301,  300,  299,  298,  297,  296,  295,  294,  293,  292, 
  876.      291,  290,  289,  288,  287,  286,  285,  284,  283,  282, 
  877.      263,  262,  260,  259,  258,  257,  126,  125,  123,   59, 
  878.       45,   43,   42,   40,   38,   33, -262, -257, -172, -258, 
  879.     -259, -260, -363, -182, -356, -261, -197, -238, -240, -176, 
  880.     -173, -174, -154, -155, -158, -159, -160, -206, -161, -162, 
  881.     -163, -164,  -25,  315,  314,  313,  312,  311,  310,  309, 
  882.      308,  306,  305,  304,  263,  262,  260,  259,  258,  257, 
  883.      126,  125,  123,   59,   45,   43,   42,   40,   38,   33, 
  884.     -215,   58, -110, -364,   59,   44, -271, -272, -273, -274, 
  885.     -275, -276, -277, -278, -279, -280, -281,  281,  280,  279, 
  886.      278,  277,  276,  275,  274,  273,  272,   61, -108,   58, 
  887.     -107,   44, -105,   44, -103,   -1, -104, -197, -305, -292, 
  888.     -293, -294, -295, -296, -297, -298, -299, -300, -301, -302, 
  889.     -229, -228, -226,  301,  300,  299,  298,  297,  296,  295, 
  890.      294,  293,  292,  291,  290,  289,  288,  282,  257,   91, 
  891.       42,   40, -262, -257, -172, -244, -258, -259, -260, -261, 
  892.     -197, -238, -240, -176, -173, -174,  263,  262,  260,  259, 
  893.      258,  257,  126,   45,   43,   42,   41,   40,   38,   33, 
  894.      -97,   -1, -104, -305, -292, -293, -294, -295, -296, -297, 
  895.     -298, -299, -300, -301, -302, -229, -228, -226,  301,  300, 
  896.      299,  298,  297,  296,  295,  294,  293,  292,  291,  290, 
  897.      289,  288,  282,   91,   42,   40,  -96,   41, -239, -110, 
  898.       44,   41, -195,   -1,  -94, -197, -305, -292, -293, -294, 
  899.     -295, -296, -297, -298, -299, -300, -301, -302, -229, -228, 
  900.     -226,  301,  300,  299,  298,  297,  296,  295,  294,  293, 
  901.      292,  291,  290,  289,  288,  282,  257,   58,   42,   40, 
  902.     -307, -305, -292, -293, -294, -295, -296, -297, -298, -299, 
  903.     -300, -301, -302, -229, -228, -226,  301,  300,  299,  298, 
  904.      297,  296,  295,  294,  293,  292,  291,  290,  289,  288, 
  905.      282,  125, -369,   59, -110,   44, -366,   59, -262, -257, 
  906.     -172, -258, -259, -260, -363, -182, -261, -197, -238, -240, 
  907.     -176, -173, -174, -154, -155, -158, -159, -160, -206, -161, 
  908.     -162, -163, -164,  -25,  315,  314,  313,  312,  311,  310, 
  909.      309,  308,  306,  305,  304,  263,  262,  260,  259,  258, 
  910.      257,  126,  123,   59,   45,   43,   42,   40,   38,   33, 
  911.     -262, -257, -172, -258, -259, -260, -363, -182, -358, -261, 
  912.     -197, -238, -240, -176, -173, -174, -154, -155, -158, -159, 
  913.     -160, -206, -161, -162, -163, -164,  -25,  315,  314,  313, 
  914.      312,  311,  310,  309,  308,  306,  305,  304,  263,  262, 
  915.      260,  259,  258,  257,  126,  125,  123,   59,   45,   43, 
  916.       42,   40,   38,   33, -216,   58, -197, -329,  302,  257, 
  917.     -324,   41, -305, -292, -293, -294, -295, -296, -297, -298, 
  918.     -299, -300, -301, -302, -229, -228, -226, -332,  302,  301, 
  919.      300,  299,  298,  297,  296,  295,  294,  293,  292,  291, 
  920.      290,  289,  288,  282, -262, -257, -172, -258, -259, -260, 
  921.     -339, -261, -197, -238, -240, -176, -173, -174,  263,  262, 
  922.      260,  259,  258,  257,  126,   93,   45,   43,   42,   40, 
  923.       38,   33,  -84,  -83,   91,   40, -103, -343,   -1, -104, 
  924.     -197, -305, -292, -293, -294, -295, -296, -297, -298, -299, 
  925.     -300, -301, -302, -229, -228, -226,  301,  300,  299,  298, 
  926.      297,  296,  295,  294,  293,  292,  291,  290,  289,  288, 
  927.      282,  257,   91,   42,   41,   40, -103, -104, -197,  257, 
  928.       91,   40, -323,   41, -110,  -80,   58,   44, -256,   41, 
  929.     -245,  -79,   44,   41, -110, -243,   93,   44,  -97, -343, 
  930.       -1, -104, -305, -292, -293, -294, -295, -296, -297, -298, 
  931.     -299, -300, -301, -302, -229, -228, -226,  301,  300,  299, 
  932.      298,  297,  296,  295,  294,  293,  292,  291,  290,  289, 
  933.      288,  282,   91,   42,   41,   40,  -97, -104,   91,   40, 
  934.     -123, -315,  125,   44,  -78,   58,  -77, -310,   59,   44, 
  935.     -306, -305, -292, -293, -294, -295, -296, -297, -298, -299, 
  936.     -300, -301, -302, -229, -228, -226,  301,  300,  299,  298, 
  937.      297,  296,  295,  294,  293,  292,  291,  290,  289,  288, 
  938.      282,  125,  -76, -348,  125,   44,  -75,   59, -208, -110, 
  939.       44,   41, -212, -110,   44,   41, -214, -110,   44,   41, 
  940.     -340,   93, -345, -305, -292, -293, -294, -295, -296, -297, 
  941.     -298, -299, -300, -301, -302, -229, -228, -226,  301,  300, 
  942.      299,  298,  297,  296,  295,  294,  293,  292,  291,  290, 
  943.      289,  288,  282,   41, -262, -257, -172, -258, -259, -260, 
  944.     -341, -261, -197, -238, -240, -176, -173, -174,  263,  262, 
  945.      260,  259,  258,  257,  126,   93,   45,   43,   42,   40, 
  946.       38,   33, -344,   41, -338,   41, -195,   -1,  -94, -197, 
  947.      257,   58,   42,   40, -262, -257, -172, -258, -259, -260, 
  948.     -119, -349, -261, -197, -238, -240, -176, -173, -174,  263, 
  949.      262,  260,  259,  258,  257,  126,  125,  123,   45,   43, 
  950.       42,   40,   38,   33, -262, -257, -172, -258, -259, -260, 
  951.      -55, -261, -197, -238, -240, -176, -173, -174,  263,  262, 
  952.      260,  259,  258,  257,  126,   59,   45,   43,   42,   40, 
  953.       38,   33,  -69,  309, -346,   41, -342,   93, -110,  -56, 
  954.       59,   44,  -64,   40, -203,   41, -201,   41,  -60, -110, 
  955.       44,   41, -210,  307, -204,   59,   -1
  956. };
  957. static short yypact[] = {
  958.       62,   90,  100,  100,   23,   62,   90,  152,  180,  182, 
  959.      223,  358,  361,  363,  365,  367,  370,  376,  382,  386, 
  960.      391,  478,  541,  545,  433,  757,  769,  223,  771,  773, 
  961.      793,  858,  955,  433, 1134, 1179,  361,  363,  365,  367, 
  962.      370,  376,  376,  382,  382,  382,  382,  386,  386,  391, 
  963.      391, 1238, 1245, 1134,  433,  433, 1453,  984,  984, 1455, 
  964.      984, 1450, 1447,  433, 1445,  984,  984,  984, 1443, 1440, 
  965.     1437, 1435,  984, 1433, 1418, 1389, 1370,  433,  433,  433, 
  966.     1365, 1363, 1348, 1318, 1301,  984, 1298, 1294, 1290, 1287, 
  967.     1284, 1266, 1248,  433, 1242,  433, 1217, 1196, 1192, 1189, 
  968.     1186, 1183, 1156, 1118, 1088, 1071, 1068,  984,  433,  433, 
  969.     1065, 1037,  433,  433,  433,  984,  957,  953,  566,  337, 
  970.      936,  901,  181,  433,  181,  880,  877,  433,  826,  181, 
  971.      181,  433,  512,  433,  433,  433,  433,  433,  433,  433, 
  972.      433,  433,  433,  433,  433,  433,  433,  433,  433,  433, 
  973.      433,  433,  744,  433,  741,  713,  639,  591,  589,  587, 
  974.      585,  181,  583,  581,   81,  566,  129,  551,  337,  548, 
  975.      543,  512,  459,  459,  433,  407,  355,  353,  337,  181, 
  976.      104,  275,  129,  226,  202,  202,  181,  166,  151,  129, 
  977.      104,   98,   94,   86,   81,   23
  978. };
  979. static short yygo[] = {
  980.       -5, -242, -225, -225, -225,  -27,  -27,  -27,  -27,  -27, 
  981.      -27,  -27, -225,  -27, -225, -331,  -27,  -27,  -27, -225, 
  982.      -24,  -24, -246, -247,  -27,  -27, -117, -225, -330, -225, 
  983.      -27,  -24, -225,  -10,   -9, -225, -225, -225, -237,  195, 
  984.      194,  193,  192,  191,  190,  186,  181,  180,  179,  164, 
  985.      161,  156,  155,  130,  129,  124,  122,  121,  115,  111, 
  986.      107,  106,  102,   85,   76,   72,   67,   66,   65,   60, 
  987.       58,   57,   35,   30,    4,  -23,  -33,  -33,  -33,  -33, 
  988.      -62,  -70,  -87,  -88,  -89,  -98, -126, -126, -101, -126, 
  989.     -153,  171,  151,  132,  131,  127,  114,  113,  112,   74, 
  990.       63,   55,   54,   33,   24,  -22,  -99, -347, -251, -270, 
  991.     -283, -347, -250, -347, -282,  165,  128,  118,  109,  108, 
  992.       78,   75, -263, -263, -263, -263, -263, -263, -263, -263, 
  993.     -263, -263, -263, -263, -263, -263, -263, -263, -263, -263, 
  994.     -263, -263, -263, -263, -263, -263, -263, -263, -252, -253, 
  995.     -263, -255, -263,  -26,  187,  175,  174,  173,  172,  153, 
  996.      150,  149,  148,  147,  146,  145,  144,  143,  142,  141, 
  997.      140,  139,  138,  137,  136,  135,  134,  133,  123,  103, 
  998.       95,   93,   82,   79,   77, -175, -264, -266, -267, -268, 
  999.     -254, -265,  174,  135,  134,  133,   95, -100, -127, -336, 
  1000.      171,  132,  -51,  -50,  -21,  137,  136,  -49,  -48,  -20, 
  1001.      139,  138,  -47,  -46,  -45,  -44,  -19,  143,  142,  141, 
  1002.      140,  -43,  -42,  -18,  145,  144,  -41,  -17,  146,  -40, 
  1003.      -16,  147,  -39,  -15,  148,  -38,  -14,  149,  -37,  -13, 
  1004.      150,  -12, -284, -236, -284, -284, -284, -284, -284, -284, 
  1005.     -269,  187,  153,  123,  103,   93,   82,   79,   77, -109, 
  1006.     -314,  -71, -313,  -85, -318, -111, -177,  153,  123,  103, 
  1007.       93,   82,   77, -372, -360, -360, -372, -359,  195,  182, 
  1008.      156,    4, -191, -233, -232, -191, -181,  195,  185,  184, 
  1009.        4, -184,   -4, -185,   -3, -328, -328, -328, -328,   -3, 
  1010.       -3,   -3,   -3,   -3,   -3,   -3,   -3, -327,  195,  189, 
  1011.      185,  184,  182,  181,  166,  156,  121,   31,   30,    5, 
  1012.        4, -186, -286, -285,  164, -335,  -53, -189,  -53,  -28, 
  1013.      -28,  -11, -189, -198,  194,  190,  180,  164,  121,  102, 
  1014.       76,   30, -351, -350, -287,  118,   75, -303, -304, -192, 
  1015.     -168,  -92, -121,  119, -169, -309, -309, -308,  120,   91, 
  1016.       -6, -122, -122, -122,  -32, -122,  -32,  -31,  171,  168, 
  1017.      132,  120,  119,   91,    0,  -93, -312, -311,   76, -193, 
  1018.      -95, -170,  124, -171, -317, -316,  122,   -7,   -7,   -2, 
  1019.      193,   35, -325, -326,  -36,  -52,  -52,  -36, -194,  102, 
  1020.       96,   31,   30,    5,    0, -178, -179,  -72, -224,  -82, 
  1021.      178,   83, -102, -180, -223, -106,  -29,  -30, -334, -333, 
  1022.      104,  -81,  -81, -337,  102,   96,  -54,  -54,  -35,   51, 
  1023.       35,  -91, -209, -200, -202, -213, -211, -207, -353, -354, 
  1024.     -217, -362, -205, -362, -361,  155,  115,  111,  107,   85, 
  1025.       72,   67,   66,   65,   60,   58,   57, -352, -375, -376, 
  1026.     -375, -222,  189,  182,  166, -221, -220, -219, -218,  -73, 
  1027.      -86, -112, -156,  156, -157, -183,  181,  -66,  -57, -365, 
  1028.      -67,  -58,  -68, -116,  -74,  -90,  -65,  -63, -118,   55, 
  1029.       54,   33,  -61,  -59, -371, -370,    4, -199, -190, -374, 
  1030.     -373,  166, -167,   -1
  1031. };
  1032. static short yypgo[] = {
  1033.        0,    0,    0,  293,  321,  350,  347,  383,  348,  405, 
  1034.      406,  413,  502,   38,  498,  495,  467,  493,  467,  492, 
  1035.      467,  484,  483,  467,  482,  479,  481,  466,  480,  478, 
  1036.      477,  470,  469,  457,  444,  444,  444,  444,  444,  415, 
  1037.      412,  389,  379,  348,  349,  349,  354,  292,  286,  286, 
  1038.      277,  277,  250,    1,    1,    1,   75,   75,  105,  105, 
  1039.      105,  105,  105,  105,  105,  105,  106,  106,  153,  153, 
  1040.      153,  153,  153,  185,  185,  185,  185,  185,  185,  191, 
  1041.      191,  204,  204,  204,  204,  114,  114,  259,  259,  259, 
  1042.      259,  259,  259,  259,  259,  259,  259,  259,   90,   90, 
  1043.      266,  291,  291,  323,  292,  292,  292,  292,  307,  307, 
  1044.      307,  307,  307,  307,  307,  307,  307,  307,  307,  307, 
  1045.      307,  307,  347,  347,  352,  352,  357,  375,  375,  377, 
  1046.      377,  348,  381,  381,  385,  389,  389,  389,  389,  389, 
  1047.      389,  398,  398,  367,  367,  414,  416,  416,  409,  417, 
  1048.      417,  419,  419,  199,  428,  428,  428,  428,  428,  428, 
  1049.      428,  428,  428,  344,  344,  344,  431,  431,  444,  457, 
  1050.      457,  461,  461,  461,  461,  475,  475,  472,  472,  465, 
  1051.      465,  466,  468,  468,  468,  468,    0,    0,  495,  497, 
  1052.      497,  500,  500,  488,  488,  479,  423,  423,  423,  199, 
  1053.      409,  414,  398,  398,  333,  333,  385,  377,  323,  286, 
  1054.      286,  250,  241,  241,  239,  239,  236,  236,  233,  233, 
  1055.      230,  230,  227,  227,  227,  223,  223,  223,  223,  223, 
  1056.      216,  216,  216,  209,  209,  209,  153,    1,    0
  1057. };
  1058. static short yyrlen[] = {
  1059.        0,    0,    0,    0,    0,    0,    2,    0,    2,    0, 
  1060.        0,    0,    0,    1,    0,    1,   10,    0,    9,    0, 
  1061.        9,    0,    0,    6,    0,    3,    0,    6,    0,    0, 
  1062.        0,    0,    0,    3,    1,    1,    1,    1,    1,    0, 
  1063.        0,    1,    1,    4,    1,    1,    0,    1,    3,    3, 
  1064.        3,    2,    5,    1,    1,    3,    1,    2,    1,    4, 
  1065.        3,    4,    3,    3,    2,    2,    1,    3,    2,    2, 
  1066.        2,    2,    4,    1,    1,    1,    1,    1,    1,    1, 
  1067.        4,    1,    3,    3,    3,    1,    3,    1,    1,    1, 
  1068.        1,    1,    1,    1,    1,    1,    1,    1,    1,    3, 
  1069.        1,    1,    3,    3,    1,    1,    1,    1,    1,    1, 
  1070.        1,    1,    1,    1,    1,    1,    1,    1,    1,    1, 
  1071.        1,    1,    6,    5,    1,    2,    3,    1,    3,    2, 
  1072.        3,    6,    1,    3,    3,    3,    3,    4,    4,    6, 
  1073.        6,    2,    3,    1,    2,    3,    1,    3,    3,    1, 
  1074.        3,    2,    1,    2,    3,    2,    3,    3,    4,    2, 
  1075.        3,    3,    4,    1,    3,    4,    1,    3,    1,    5, 
  1076.        4,    2,    3,    3,    4,    1,    2,    1,    2,    1, 
  1077.        2,    8,    3,    2,    2,    3,    1,    2,    1,    3, 
  1078.        4,    1,    2,    1,    0,    0,    2,    1,    1,    1, 
  1079.        1,    1,    2,    1,    2,    1,    1,    1,    1,    1, 
  1080.        1,    1,    3,    1,    3,    1,    3,    1,    3,    1, 
  1081.        3,    1,    3,    3,    1,    3,    3,    3,    3,    1, 
  1082.        3,    3,    1,    3,    3,    1,    1,    1,    2
  1083. };
  1084. #define YYS0    195
  1085. #define YYDELTA    183
  1086. #define YYNPACT    196
  1087. #define YYNDEF    57
  1088.  
  1089. #define YYr236    0
  1090. #define YYr237    1
  1091. #define YYr238    2
  1092. #define YYr80    3
  1093. #define YYr83    4
  1094. #define YYr108    5
  1095. #define YYr112    6
  1096. #define YYr124    7
  1097. #define YYr126    8
  1098. #define YYr138    9
  1099. #define YYr140    10
  1100. #define YYr143    11
  1101. #define YYr231    12
  1102. #define YYr235    13
  1103. #define YYr229    14
  1104. #define YYr227    15
  1105. #define YYr218    16
  1106. #define YYr217    17
  1107. #define YYr216    18
  1108. #define YYr215    19
  1109. #define YYr214    20
  1110. #define YYr213    21
  1111. #define YYr212    22
  1112. #define YYr211    23
  1113. #define YYr210    24
  1114. #define YYr209    25
  1115. #define YYr208    26
  1116. #define YYr206    27
  1117. #define YYr205    28
  1118. #define YYr203    29
  1119. #define YYr202    30
  1120. #define YYr190    31
  1121. #define YYr188    32
  1122. #define YYr187    33
  1123. #define YYr186    34
  1124. #define YYr185    35
  1125. #define YYr184    36
  1126. #define YYr183    37
  1127. #define YYr182    38
  1128. #define YYr144    39
  1129. #define YYr141    40
  1130. #define YYr134    41
  1131. #define YYr127    42
  1132. #define YYr123    43
  1133. #define YYr114    44
  1134. #define YYr113    45
  1135. #define YYr110    46
  1136. #define YYr89    47
  1137. #define YYr84    48
  1138. #define YYr81    49
  1139. #define YYr78    50
  1140. #define YYr77    51
  1141. #define YYr60    52
  1142. #define YYrACCEPT    YYr236
  1143. #define YYrERROR    YYr237
  1144. #define YYrLR2    YYr238
  1145. #line 2 "c:\mks/etc/yyparse.c"
  1146.  
  1147. /*
  1148.  * Copyright 1985, 1990 by Mortice Kern Systems Inc.  All rights reserved.
  1149.  * 
  1150.  * Automaton to interpret LALR(1) tables.
  1151.  *
  1152.  *    Macros:
  1153.  *        yyclearin - clear the lookahead token.
  1154.  *        yyerrok - forgive a pending error
  1155.  *        YYERROR - simulate an error
  1156.  *        YYACCEPT - halt and return 0
  1157.  *        YYABORT - halt and return 1
  1158.  *        YYRETURN(value) - halt and return value.  You should use this
  1159.  *            instead of return(value).
  1160.  *        YYREAD - ensure yychar contains a lookahead token by reading
  1161.  *            one if it does not.  See also YYSYNC.
  1162.  *        YYRECOVERING - 1 if syntax error detected and not recovered
  1163.  *            yet; otherwise, 0.
  1164.  *
  1165.  *    Preprocessor flags:
  1166.  *        YYDEBUG - includes debug code.  The parser will print
  1167.  *             a travelogue of the parse if this is defined
  1168.  *             and yydebug is non-zero.
  1169.  *        YYSSIZE - size of state and value stacks (default 150).
  1170.  *        YYSTATIC - By default, the state stack is an automatic array.
  1171.  *            If this is defined, the stack will be static.
  1172.  *            In either case, the value stack is static.
  1173.  *        YYALLOC - Dynamically allocate both the state and value stacks
  1174.  *            by calling malloc() and free().
  1175.  *        YYLR2 - defined if lookahead is needed to resolve R/R or S/R conflicts
  1176.  *        YYSYNC - if defined, yacc guarantees to fetch a lookahead token
  1177.  *            before any action, even if it doesnt need it for a decision.
  1178.  *            If YYSYNC is defined, YYREAD will never be necessary unless
  1179.  *            the user explicitly sets yychar = -1
  1180.  *
  1181.  *    Copyright (c) 1983, by the University of Waterloo
  1182.  */
  1183.  
  1184. /* GENTEXT: yyerror */
  1185. #ifndef I18N
  1186. #define    gettext(x)    x
  1187. #endif
  1188.  
  1189. #ifndef YYSSIZE
  1190. # define YYSSIZE    150
  1191. #endif
  1192.  
  1193. #define YYERROR        goto yyerrlabel
  1194. #define yyerrok        yyerrflag = 0
  1195. #define yyclearin    yychar = -1
  1196. #define YYACCEPT    YYRETURN(0)
  1197. #define YYABORT        YYRETURN(1)
  1198. #define YYRECOVERING()    (yyerrflag != 0)
  1199. #ifdef YYALLOC
  1200. # define YYRETURN(val)    { retval = (val); goto yyReturn; }
  1201. #else
  1202. # define YYRETURN(val)    return(val)
  1203. #endif
  1204. #ifdef YYDEBUG
  1205. /* The if..else makes this macro behave exactly like a statement */
  1206. # define YYREAD    if (yychar < 0) {                    \
  1207.             if ((yychar = yylex()) < 0)            \
  1208.                 yychar = 0;                \
  1209.             if (yydebug)                    \
  1210.                 printf(gettext("read %s (%d)\n"),     \
  1211.                 yyptok(yychar),                \
  1212.                 yychar);                \
  1213.         } else
  1214. #else
  1215. # define YYREAD    if (yychar < 0) {                    \
  1216.             if ((yychar = yylex()) < 0)            \
  1217.                 yychar = 0;                \
  1218.         } else
  1219. #endif
  1220. #define YYERRCODE    256        /* value of `error' */
  1221. #if 0 && defined(__TURBOC__) && __SMALL__
  1222.     /* THIS ONLY WORKS ON TURBO C 1.5 !!! */
  1223. #define    YYQYYP    *(int *)((int)yyq + ((int)yyq-(int)yyp))
  1224. #else
  1225. #define    YYQYYP    yyq[yyq-yyp]
  1226. #endif
  1227.  
  1228. YYSTYPE    yyval;                /* $$ */
  1229. YYSTYPE    *yypvt;                /* $n */
  1230. YYSTYPE    yylval;                /* yylex() sets this */
  1231.  
  1232. int    yychar,                /* current token */
  1233.     yyerrflag,            /* error flag */
  1234.     yynerrs;            /* error count */
  1235.  
  1236. #ifdef YYDEBUG
  1237. int yydebug = 0;        /* debug flag & tables */
  1238. extern char    *yysvar[], *yystoken[], *yyptok();
  1239. extern short    yyrmap[], yysmap[];
  1240. extern int    yynstate, yynvar, yyntoken, yynrule;
  1241. # define yyassert(condition, msg, arg) \
  1242.     if (!(condition)) { printf(gettext("\nyacc bug: ")); printf(msg, arg); YYABORT; }
  1243. #else /* !YYDEBUG */
  1244. # define yyassert(condition, msg, arg)
  1245. #endif
  1246.  
  1247. yyparse()
  1248. {
  1249.  
  1250.     register short        yyi, *yyp;    /* for table lookup */
  1251.     register short        *yyps;        /* top of state stack */
  1252.     register short        yystate;    /* current state */
  1253.     register YYSTYPE    *yypv;        /* top of value stack */
  1254.     register short        *yyq;
  1255.     register int        yyj;
  1256.  
  1257. #ifdef YYSTATIC
  1258.     static short    yys[YYSSIZE + 1];
  1259.     static YYSTYPE    yyv[YYSSIZE + 1];
  1260. #else
  1261. #ifdef YYALLOC
  1262.     YYSTYPE *yyv;
  1263.     short    *yys;
  1264.     YYSTYPE save_yylval;
  1265.     YYSTYPE save_yyval;
  1266.     YYSTYPE *save_yypvt;
  1267.     int save_yychar, save_yyerrflag, save_yynerrs;
  1268.     int retval;
  1269. #if 0    /* defined in <stdlib.h>*/
  1270.     extern char    *malloc();
  1271. #endif
  1272. #else
  1273.     short        yys[YYSSIZE + 1];
  1274.     static YYSTYPE    yyv[YYSSIZE + 1];    /* historically static */
  1275. #endif
  1276. #endif
  1277.  
  1278. #ifdef YYALLOC
  1279.     yys = (short *) malloc((YYSSIZE + 1) * sizeof(short));
  1280.     yyv = (YYSTYPE *) malloc((YYSSIZE + 1) * sizeof(YYSTYPE));
  1281.     if (yys == (short *)0 || yyv == (YYSTYPE *)0) {
  1282.         yyerror("Not enough space for parser stacks");
  1283.         return 1;
  1284.     }
  1285.     save_yylval = yylval;
  1286.     save_yyval = yyval;
  1287.     save_yypvt = yypvt;
  1288.     save_yychar = yychar;
  1289.     save_yyerrflag = yyerrflag;
  1290.     save_yynerrs = yynerrs;
  1291. #endif
  1292.  
  1293.     yynerrs = 0;
  1294.     yyerrflag = 0;
  1295.     yychar = -1;
  1296.     yyps = yys;
  1297.     yypv = yyv;
  1298.     yystate = YYS0;        /* start state */
  1299.  
  1300. yyStack:
  1301.     yyassert((unsigned)yystate < yynstate, gettext("state %d\n"), yystate);
  1302.     if (++yyps > &yys[YYSSIZE]) {
  1303.         yyerror("Parser stack overflow");
  1304.         YYABORT;
  1305.     }
  1306.     *yyps = yystate;    /* stack current state */
  1307.     *++yypv = yyval;    /* ... and value */
  1308.  
  1309. #ifdef YYDEBUG
  1310.     if (yydebug)
  1311.         printf(gettext("state %d (%d), char %s (%d)\n"),yysmap[yystate],
  1312.             yystate, yyptok(yychar), yychar);
  1313. #endif
  1314.  
  1315.     /*
  1316.      *    Look up next action in action table.
  1317.      */
  1318. yyEncore:
  1319. #ifdef YYSYNC
  1320.     YYREAD;
  1321. #endif
  1322.     if (yystate >= sizeof yypact/sizeof yypact[0])     /* simple state */
  1323.         yyi = yystate - YYDELTA;    /* reduce in any case */
  1324.     else {
  1325.         if(*(yyp = &yyact[yypact[yystate]]) >= 0) {
  1326.             /* Look for a shift on yychar */
  1327. #ifndef YYSYNC
  1328.             YYREAD;
  1329. #endif
  1330.             yyq = yyp;
  1331.             yyi = yychar;
  1332. #if 0 && defined(__TURBOC__) && __SMALL__
  1333.     /* THIS ONLY WORKS ON TURBO C 1.5 !!! */
  1334.             /* yyi is in di, yyp is in si */
  1335.         L01:
  1336.             asm lodsw    /* ax = *yyp++; */
  1337.             asm cmp yyi, ax
  1338.             asm jl L01
  1339. #else
  1340.             while (yyi < *yyp++)
  1341.                 ;
  1342. #endif
  1343.             if (yyi == yyp[-1]) {
  1344.                 yystate = ~YYQYYP;
  1345. #ifdef YYDEBUG
  1346.                 if (yydebug)
  1347.                     printf(gettext("shift %d (%d)\n"),
  1348.                         yysmap[yystate], yystate);
  1349. #endif
  1350.                 yyval = yylval;        /* stack what yylex() set */
  1351.                 yychar = -1;        /* clear token */
  1352.                 if (yyerrflag)
  1353.                     yyerrflag--;    /* successful shift */
  1354.                 goto yyStack;
  1355.             }
  1356.         }
  1357.  
  1358.         /*
  1359.           *    Fell through - take default action
  1360.           */
  1361.  
  1362.         if (yystate >= sizeof yydef /sizeof yydef[0])
  1363.             goto yyError;
  1364.         if ((yyi = yydef[yystate]) < 0)     { /* default == reduce? */
  1365.                                             /* Search exception table */
  1366.             yyassert((unsigned)~yyi < sizeof yyex/sizeof yyex[0],
  1367.                 gettext("exception %d\n"), yystate);
  1368.             yyp = &yyex[~yyi];
  1369. #ifndef YYSYNC
  1370.             YYREAD;
  1371. #endif
  1372.             while((yyi = *yyp) >= 0 && yyi != yychar)
  1373.                 yyp += 2;
  1374.             yyi = yyp[1];
  1375.             yyassert(yyi >= 0,
  1376.                  gettext("Ex table not reduce %d\n"), yyi);
  1377.         }
  1378.     }
  1379.  
  1380. #ifdef YYLR2
  1381. yyReduce:    /* reduce yyi */
  1382. #endif
  1383.     yyassert((unsigned)yyi < yynrule, gettext("reduce %d\n"), yyi);
  1384.     yyj = yyrlen[yyi];
  1385. #ifdef YYDEBUG
  1386.     if (yydebug) printf(gettext("reduce %d (%d), pops %d (%d)\n"), 
  1387.         yyrmap[yyi], yyi, yysmap[yyps[-yyj]], yyps[-yyj]);
  1388. #endif
  1389.     yyps -= yyj;        /* pop stacks */
  1390.     yypvt = yypv;        /* save top */
  1391.     yypv -= yyj;
  1392.     yyval = yypv[1];    /* default action $$ = $1 */
  1393.     switch (yyi) {        /* perform semantic action */
  1394.         
  1395. case YYr60: {    /* conditional_expr :  logical_or_expr '?' expr ':' conditional_expr */
  1396. #line 157 "gram.y"
  1397.  ++fcn_decisions; 
  1398. } break;
  1399.  
  1400. case YYr77: {    /* declaration :  declaration_specifiers ';' */
  1401. #line 194 "gram.y"
  1402.  is_typedef = FALSE; 
  1403. } break;
  1404.  
  1405. case YYr78: {    /* declaration :  declaration_specifiers init_declarator_list ';' */
  1406. #line 196 "gram.y"
  1407.  is_typedef = FALSE; 
  1408. } break;
  1409.  
  1410. case YYr80: {    /* declaration_specifiers :  storage_class_specifier */
  1411. #line 207 "gram.y"
  1412.  ++nested_decl_specs; 
  1413. } break;
  1414.  
  1415. case YYr81: {    /* declaration_specifiers :  storage_class_specifier $80 declaration_specifiers */
  1416. #line 209 "gram.y"
  1417.  --nested_decl_specs; 
  1418. } break;
  1419.  
  1420. case YYr83: {    /* declaration_specifiers :  type_specifier */
  1421. #line 212 "gram.y"
  1422.  ++nested_decl_specs; 
  1423. } break;
  1424.  
  1425. case YYr84: {    /* declaration_specifiers :  type_specifier $83 declaration_specifiers */
  1426. #line 214 "gram.y"
  1427.  --nested_decl_specs; 
  1428. } break;
  1429.  
  1430. case YYr89: {    /* storage_class_specifier :  TK_TYPEDEF */
  1431. #line 233 "gram.y"
  1432.  is_typedef = TRUE; 
  1433. } break;
  1434.  
  1435. case YYr108: {    /* struct_or_union_specifier :  struct_or_union identifier */
  1436. #line 263 "gram.y"
  1437.  looking_for_tag = FALSE; 
  1438. } break;
  1439.  
  1440. case YYr110: {    /* struct_or_union_specifier :  struct_or_union '{' */
  1441. #line 266 "gram.y"
  1442.  looking_for_tag = FALSE; 
  1443. } break;
  1444.  
  1445. case YYr112: {    /* struct_or_union_specifier :  struct_or_union identifier */
  1446. #line 269 "gram.y"
  1447.  looking_for_tag = FALSE; 
  1448. } break;
  1449.  
  1450. case YYr113: {    /* struct_or_union :  TK_STRUCT */
  1451. #line 280 "gram.y"
  1452.  looking_for_tag = TRUE; 
  1453. } break;
  1454.  
  1455. case YYr114: {    /* struct_or_union :  TK_UNION */
  1456. #line 282 "gram.y"
  1457.  looking_for_tag = TRUE; 
  1458. } break;
  1459.  
  1460. case YYr123: {    /* enum_specifier :  enum '{' enumerator_list '}' */
  1461. #line 311 "gram.y"
  1462.  looking_for_tag = FALSE; 
  1463. } break;
  1464.  
  1465. case YYr124: {    /* enum_specifier :  enum identifier */
  1466. #line 313 "gram.y"
  1467.  looking_for_tag = FALSE; 
  1468. } break;
  1469.  
  1470. case YYr126: {    /* enum_specifier :  enum identifier */
  1471. #line 316 "gram.y"
  1472.  looking_for_tag = FALSE; 
  1473. } break;
  1474.  
  1475. case YYr127: {    /* enum :  TK_ENUM */
  1476. #line 325 "gram.y"
  1477.  looking_for_tag = TRUE; 
  1478. } break;
  1479.  
  1480. case YYr134: {    /* declarator2 :  identifier */
  1481. #line 345 "gram.y"
  1482.  
  1483.          
  1484.          if (is_typedef && nested_decl_specs == 0)
  1485.            typedef_symbol_table_add(token());
  1486.       
  1487. } break;
  1488.  
  1489. case YYr138: {    /* declarator2 :  declarator2 '(' */
  1490. #line 363 "gram.y"
  1491.  
  1492.          if (!is_within_function)
  1493.             strcpy(function_name, last_identifier);
  1494.       
  1495. } break;
  1496.  
  1497. case YYr140: {    /* declarator2 :  declarator2 '(' */
  1498. #line 374 "gram.y"
  1499.  
  1500.          ++nested_decl_specs;
  1501.          if (!is_within_function)
  1502.             strcpy(function_name, last_identifier);
  1503.       
  1504. } break;
  1505.  
  1506. case YYr141: {    /* declarator2 :  declarator2 '(' $140 parameter_type_list */
  1507. #line 380 "gram.y"
  1508.  --nested_decl_specs; 
  1509. } break;
  1510.  
  1511. case YYr143: {    /* declarator2 :  declarator2 '(' */
  1512. #line 383 "gram.y"
  1513.  
  1514.          ++nested_decl_specs;
  1515.          if (!is_within_function)
  1516.             strcpy(function_name, last_identifier);
  1517.       
  1518. } break;
  1519.  
  1520. case YYr144: {    /* declarator2 :  declarator2 '(' $143 parameter_identifier_list */
  1521. #line 389 "gram.y"
  1522.  --nested_decl_specs; 
  1523. } break;
  1524.  
  1525. case YYr182: {    /* statement :  compound_statement */
  1526. #line 467 "gram.y"
  1527.  
  1528.          is_else = is_if = FALSE;
  1529.  
  1530.          ++int_fcn.high;      
  1531.  
  1532.          
  1533.          not_case_label();
  1534.  
  1535.          
  1536.          int_stm.is_comp = int_stm.is_high = int_stm.end = TRUE;
  1537.          int_stm.depth = depth;
  1538.          fire_stm();
  1539.          ZERO(int_stm);
  1540.       
  1541. } break;
  1542.  
  1543. case YYr183: {    /* statement :  expression_statement */
  1544. #line 485 "gram.y"
  1545.  
  1546.          check_multiple_statements();
  1547.  
  1548.          ++int_fcn.low;          
  1549.  
  1550.          
  1551.          not_case_label();
  1552.  
  1553.          
  1554.          int_stm.is_expr = int_stm.is_low = int_stm.end = TRUE;
  1555.          int_stm.depth = depth;
  1556.          fire_stm();
  1557.          ZERO(int_stm);
  1558.       
  1559. } break;
  1560.  
  1561. case YYr184: {    /* statement :  selection_statement */
  1562. #line 503 "gram.y"
  1563.  
  1564.          ++int_fcn.high;      
  1565.  
  1566.          
  1567.          not_case_label();
  1568.  
  1569.          
  1570.          int_stm.is_select = int_stm.is_high = int_stm.end = TRUE;
  1571.          int_stm.depth = depth;
  1572.          fire_stm();
  1573.          ZERO(int_stm);
  1574.       
  1575. } break;
  1576.  
  1577. case YYr185: {    /* statement :  iteration_statement */
  1578. #line 519 "gram.y"
  1579.  
  1580.          ++int_fcn.high;      
  1581.  
  1582.          
  1583.          not_case_label();
  1584.  
  1585.          
  1586.          int_stm.is_iter = int_stm.is_high = int_stm.end = TRUE;
  1587.          int_stm.depth = depth;
  1588.          fire_stm();
  1589.          ZERO(int_stm);
  1590.       
  1591. } break;
  1592.  
  1593. case YYr186: {    /* statement :  jump_statement */
  1594. #line 535 "gram.y"
  1595.  
  1596.          check_multiple_statements();
  1597.  
  1598.          ++int_fcn.low;          
  1599.  
  1600.          
  1601.          not_case_label();
  1602.  
  1603.          
  1604.          int_stm.is_jump = int_stm.is_low = int_stm.end = TRUE;
  1605.          int_stm.depth = depth;
  1606.          fire_stm();
  1607.          ZERO(int_stm);
  1608.       
  1609. } break;
  1610.  
  1611. case YYr187: {    /* labeled_statement :  identifier ':' statement */
  1612. #line 556 "gram.y"
  1613.  is_else = is_if = FALSE; 
  1614. } break;
  1615.  
  1616. case YYr188: {    /* labeled_statement :  TK_CASE constant_expr ':' */
  1617. #line 558 "gram.y"
  1618.  
  1619.          check_multiple_statements();
  1620.  
  1621.          
  1622.          case_label();
  1623.       
  1624. } break;
  1625.  
  1626. case YYr190: {    /* labeled_statement :  TK_DEFAULT ':' */
  1627. #line 566 "gram.y"
  1628.  check_multiple_statements(); 
  1629. } break;
  1630.  
  1631. case YYr202: {    /* selection_statement :  TK_IF '(' expr ')' */
  1632. #line 594 "gram.y"
  1633.  
  1634.          is_if = TRUE;
  1635.          check_multiple_statements();
  1636.          ++depth;                
  1637.          ++fcn_decisions;        
  1638.       
  1639. } break;
  1640.  
  1641. case YYr203: {    /* selection_statement :  TK_IF '(' expr ')' $202 statement */
  1642. #line 601 "gram.y"
  1643.  --depth;                  
  1644. } break;
  1645.  
  1646. case YYr205: {    /* selection_statement :  TK_SWITCH '(' expr ')' */
  1647. #line 604 "gram.y"
  1648.  
  1649.          check_multiple_statements();
  1650.          ++depth;                
  1651.       
  1652. } break;
  1653.  
  1654. case YYr206: {    /* selection_statement :  TK_SWITCH '(' expr ')' $205 statement */
  1655. #line 609 "gram.y"
  1656.  --depth;                  
  1657. } break;
  1658.  
  1659. case YYr208: {    /* opt_else :  TK_ELSE */
  1660. #line 615 "gram.y"
  1661.  
  1662.          check_multiple_statements();
  1663.          is_else = TRUE;         
  1664.          ++depth;                
  1665.       
  1666. } break;
  1667.  
  1668. case YYr209: {    /* opt_else :  TK_ELSE $208 statement */
  1669. #line 621 "gram.y"
  1670.  --depth;                  
  1671. } break;
  1672.  
  1673. case YYr210: {    /* iteration_statement :  TK_WHILE '(' expr ')' */
  1674. #line 626 "gram.y"
  1675.  
  1676.          check_multiple_statements();
  1677.          ++depth;                
  1678.          ++fcn_decisions;        
  1679.       
  1680. } break;
  1681.  
  1682. case YYr211: {    /* iteration_statement :  TK_WHILE '(' expr ')' $210 statement */
  1683. #line 632 "gram.y"
  1684.  --depth;                  
  1685. } break;
  1686.  
  1687. case YYr212: {    /* iteration_statement :  TK_DO */
  1688. #line 634 "gram.y"
  1689.  
  1690.          ++depth;                
  1691.          ++fcn_decisions;        
  1692.       
  1693. } break;
  1694.  
  1695. case YYr213: {    /* iteration_statement :  TK_DO $212 statement */
  1696. #line 639 "gram.y"
  1697.  --depth;                  
  1698. } break;
  1699.  
  1700. case YYr214: {    /* iteration_statement :  TK_DO $212 statement $213 TK_WHILE '(' expr ')' ';' */
  1701. #line 641 "gram.y"
  1702.  check_multiple_statements(); 
  1703. } break;
  1704.  
  1705. case YYr215: {    /* iteration_statement :  TK_FOR '(' opt_expr ';' ';' opt_expr ')' */
  1706. #line 643 "gram.y"
  1707.  
  1708.          check_multiple_statements();
  1709.          ++depth;                
  1710.          
  1711.       
  1712. } break;
  1713.  
  1714. case YYr216: {    /* iteration_statement :  TK_FOR '(' opt_expr ';' ';' opt_expr ')' $215 statement */
  1715. #line 649 "gram.y"
  1716.  --depth;                  
  1717. } break;
  1718.  
  1719. case YYr217: {    /* iteration_statement :  TK_FOR '(' opt_expr ';' expr ';' opt_expr ')' */
  1720. #line 651 "gram.y"
  1721.  
  1722.          check_multiple_statements();
  1723.          ++depth;                
  1724.          ++fcn_decisions;        
  1725.       
  1726. } break;
  1727.  
  1728. case YYr218: {    /* iteration_statement :  TK_FOR '(' opt_expr ';' expr ';' opt_expr ')' $217 statement */
  1729. #line 657 "gram.y"
  1730.  --depth;                  
  1731. } break;
  1732.  
  1733. case YYr227: {    /* external_declaration :  function_definition */
  1734. #line 679 "gram.y"
  1735.  stat_func_end(); 
  1736. } break;
  1737.  
  1738. case YYr229: {    /* function_definition :  declarator */
  1739. #line 685 "gram.y"
  1740.  stat_func_begin(); 
  1741. } break;
  1742.  
  1743. case YYr231: {    /* function_definition :  declaration_specifiers declarator */
  1744. #line 688 "gram.y"
  1745.  stat_func_begin(); 
  1746. } break;
  1747.  
  1748. case YYr235: {    /* identifier :  TK_IDENTIFIER */
  1749. #line 699 "gram.y"
  1750.  
  1751.          
  1752.          strcpy(last_identifier, token());
  1753.       
  1754. } break;
  1755. #line 237 "c:\mks/etc/yyparse.c"
  1756.     case YYrACCEPT:
  1757.         YYACCEPT;
  1758.     case YYrERROR:
  1759.         goto yyError;
  1760. #ifdef YYLR2
  1761.     case YYrLR2:
  1762. #ifndef YYSYNC
  1763.         YYREAD;
  1764. #endif
  1765.         yyj = 0;
  1766.         while(yylr2[yyj] >= 0) {
  1767.             if(yylr2[yyj] == yystate && yylr2[yyj+1] == yychar
  1768.             && yylook(yys+1,yyps,yystate,yychar,yy2lex(),yylr2[yyj+2]))
  1769.                     break;
  1770.             yyj += 3;
  1771.         }
  1772.         if(yylr2[yyj] < 0)
  1773.             goto yyError;
  1774.         if(yylr2[yyj+2] < 0) {
  1775.             yystate = ~ yylr2[yyj+2];
  1776.             goto yyStack;
  1777.         }
  1778.         yyi = yylr2[yyj+2];
  1779.         goto yyReduce;
  1780. #endif
  1781.     }
  1782.  
  1783.     /*
  1784.      *    Look up next state in goto table.
  1785.      */
  1786.  
  1787.     yyp = &yygo[yypgo[yyi]];
  1788.     yyq = yyp++;
  1789.     yyi = *yyps;
  1790. #if    0 && defined(__TURBOC__) && __SMALL__
  1791.     /* THIS ONLY WORKS ON TURBO C 1.5 !!! */
  1792.     /* yyi is in di, yyp is in si */
  1793. L02:
  1794.     asm lodsw        /* ax = *yyp++; */
  1795.     asm cmp yyi, ax
  1796.     asm jl L02
  1797. #else
  1798.     while (yyi < *yyp++)
  1799.         ;
  1800. #endif
  1801.     yystate = ~(yyi == *--yyp? YYQYYP: *yyq);
  1802.     goto yyStack;
  1803.  
  1804. yyerrlabel:    ;        /* come here from YYERROR    */
  1805. /*
  1806. #pragma used yyerrlabel
  1807.  */
  1808.     yyerrflag = 1;
  1809.     if (yyi == YYrERROR)
  1810.         yyps--, yypv--;
  1811.     
  1812. yyError:
  1813.     switch (yyerrflag) {
  1814.  
  1815.     case 0:        /* new error */
  1816.         yynerrs++;
  1817.         yyi = yychar;
  1818.         yyerror("Syntax error");
  1819.         if (yyi != yychar) {
  1820.             /* user has changed the current token */
  1821.             /* try again */
  1822.             yyerrflag++;    /* avoid loops */
  1823.             goto yyEncore;
  1824.         }
  1825.  
  1826.     case 1:        /* partially recovered */
  1827.     case 2:
  1828.         yyerrflag = 3;    /* need 3 valid shifts to recover */
  1829.             
  1830.         /*
  1831.          *    Pop states, looking for a
  1832.          *    shift on `error'.
  1833.          */
  1834.  
  1835.         for ( ; yyps > yys; yyps--, yypv--) {
  1836.             if (*yyps >= sizeof yypact/sizeof yypact[0])
  1837.                 continue;
  1838.             yyp = &yyact[yypact[*yyps]];
  1839.             yyq = yyp;
  1840.             do
  1841.                 ;
  1842.             while (YYERRCODE < *yyp++);
  1843.             if (YYERRCODE == yyp[-1]) {
  1844.                 yystate = ~YYQYYP;
  1845.                 goto yyStack;
  1846.             }
  1847.                 
  1848.             /* no shift in this state */
  1849. #ifdef YYDEBUG
  1850.             if (yydebug && yyps > yys+1)
  1851.                 printf(
  1852.     gettext("Error recovery pops state %d (%d), uncovers %d (%d)\n"),
  1853.                     yysmap[yyps[0]], yyps[0],
  1854.                     yysmap[yyps[-1]], yyps[-1]);
  1855. #endif
  1856.             /* pop stacks; try again */
  1857.         }
  1858.         /* no shift on error - abort */
  1859.         break;
  1860.  
  1861.     case 3:
  1862.         /*
  1863.          *    Erroneous token after
  1864.          *    an error - discard it.
  1865.          */
  1866.  
  1867.         if (yychar == 0)  /* but not EOF */
  1868.             break;
  1869. #ifdef YYDEBUG
  1870.         if (yydebug)
  1871.             printf(gettext("Error recovery discards %s (%d), "),
  1872.                 yyptok(yychar), yychar);
  1873. #endif
  1874.         yyclearin;
  1875.         goto yyEncore;    /* try again in same state */
  1876.     }
  1877.     YYABORT;
  1878.  
  1879. #ifdef YYALLOC
  1880. yyReturn:
  1881.     yylval = save_yylval;
  1882.     yyval = save_yyval;
  1883.     yypvt = save_yypvt;
  1884.     yychar = save_yychar;
  1885.     yyerrflag = save_yyerrflag;
  1886.     yynerrs = save_yynerrs;
  1887.     free((char *)yys);
  1888.     free((char *)yyv);
  1889.     return(retval);
  1890. #endif
  1891. }
  1892.  
  1893. #ifdef YYLR2
  1894. yylook(s,rsp,state,c1,c2,i)
  1895. short *s;        /* stack        */
  1896. short *rsp;        /* real top of stack    */
  1897. int state;        /* current state    */
  1898. int c1;            /* current char        */
  1899. int c2;            /* next char        */
  1900. int i;            /* action S < 0, R >= 0    */
  1901. {
  1902.     int j;
  1903.     short *p,*q;
  1904.     short *sb,*st;
  1905. #ifdef YYDEBUG
  1906.     if(yydebug) {
  1907.     printf(gettext("LR2 state %d (%d) char %s (%d) lookahead %s (%d)"),
  1908.             yysmap[state],state,yyptok(c1),c1,yyptok(c2),c2);
  1909.         if(i > 0)
  1910.             printf(gettext("reduce %d (%d)\n"), yyrmap[i], i);
  1911.         else
  1912.             printf(gettext("shift %d (%d)\n"), yysmap[i], i);
  1913.     }
  1914. #endif
  1915.     st = sb = rsp+1;
  1916.     if(i >= 0)
  1917.         goto reduce;
  1918.   shift:
  1919.     state = ~i;
  1920.     c1 = c2;
  1921.     if(c1 < 0)
  1922.         return 1;
  1923.     c2 = -1;
  1924.  
  1925.   stack:
  1926.       if(++st >= &s[YYSSIZE]) {
  1927.         yyerror("Parser Stack Overflow");
  1928.         return 0;
  1929.     }
  1930.     *st = state;
  1931.     if(state >= sizeof yypact/sizeof yypact[0])
  1932.         i = state- YYDELTA;
  1933.     else {
  1934.         p = &yyact[yypact[state]];
  1935.         q = p;
  1936.         i = c1;
  1937.         while(i < *p++)
  1938.             ;
  1939.         if(i == p[-1]) {
  1940.             state = ~q[q-p];
  1941.             c1 = c2;
  1942.             if(c1 < 0)
  1943.                 return 1;
  1944.             c2 = -1;
  1945.             goto stack;
  1946.         }
  1947.         if(state >= sizeof yydef/sizeof yydef[0])
  1948.             return 0;
  1949.         if((i = yydef[state]) < 0) {
  1950.             p = &yyex[~i];
  1951.             while((i = *p) >= 0 && i != c1)
  1952.                 p += 2;
  1953.             i = p[1];
  1954.         }
  1955.     }
  1956.   reduce:
  1957.       j = yyrlen[i];
  1958.     if(st-sb >= j)
  1959.         st -= j;
  1960.     else {
  1961.         rsp -= j+st-sb;
  1962.         st = sb;
  1963.     }
  1964.     switch(i) {
  1965.     case YYrERROR:
  1966.         return 0;
  1967.     case YYrACCEPT:
  1968.         return 1;
  1969.     case YYrLR2:
  1970.         j = 0;
  1971.         while(yylr2[j] >= 0) {
  1972.             if(yylr2[j] == state && yylr2[j+1] == c1)
  1973.                 if((i = yylr2[j+2]) < 0)
  1974.                     goto shift;
  1975.                 else
  1976.                     goto reduce;
  1977.         }
  1978.         return 0;
  1979.     }
  1980.     p = &yygo[yypgo[i]];
  1981.     q = p++;
  1982.     i = st==sb ? *rsp : *st;
  1983.     while(i < *p++);
  1984.     state = ~(i == *--p? q[q-p]: *q);
  1985.     goto stack;
  1986. }
  1987. #endif
  1988.         
  1989. #ifdef YYDEBUG
  1990.     
  1991. /*
  1992.  *    Print a token legibly.
  1993.  *    This won't work if you roll your own token numbers,
  1994.  *    but I've found it useful.
  1995.  */
  1996. char *
  1997. yyptok(i)
  1998. {
  1999.     static char    buf[10];
  2000.  
  2001.     if (i >= YYERRCODE)
  2002.         return yystoken[i-YYERRCODE];
  2003.     if (i < 0)
  2004.         return "";
  2005.     if (i == 0)
  2006.         return "$end";
  2007.     if (i < ' ')
  2008.         sprintf(buf, "'^%c'", i+'@');
  2009.     else
  2010.         sprintf(buf, "'%c'", i);
  2011.     return buf;
  2012. }
  2013. #endif
  2014. #ifdef YYDEBUG
  2015. char * yystoken[] = {
  2016.     "error",
  2017.     "TK_IDENTIFIER",
  2018.     "TK_CONSTANT",
  2019.     "TK_STRING_LITERAL",
  2020.     "TK_SIZEOF",
  2021.     "TK_PTR_OP",
  2022.     "TK_INC_OP",
  2023.     "TK_DEC_OP",
  2024.     "TK_LEFT_OP",
  2025.     "TK_RIGHT_OP",
  2026.     "TK_LE_OP",
  2027.     "TK_GE_OP",
  2028.     "TK_EQ_OP",
  2029.     "TK_NE_OP",
  2030.     "TK_AND_OP",
  2031.     "TK_OR_OP",
  2032.     "TK_MUL_ASSIGN",
  2033.     "TK_DIV_ASSIGN",
  2034.     "TK_MOD_ASSIGN",
  2035.     "TK_ADD_ASSIGN",
  2036.     "TK_SUB_ASSIGN",
  2037.     "TK_LEFT_ASSIGN",
  2038.     "TK_RIGHT_ASSIGN",
  2039.     "TK_AND_ASSIGN",
  2040.     "TK_XOR_ASSIGN",
  2041.     "TK_OR_ASSIGN",
  2042.     "TK_TYPE_NAME",
  2043.     "TK_TYPEDEF",
  2044.     "TK_EXTERN",
  2045.     "TK_STATIC",
  2046.     "TK_AUTO",
  2047.     "TK_REGISTER",
  2048.     "TK_CHAR",
  2049.     "TK_SHORT",
  2050.     "TK_INT",
  2051.     "TK_LONG",
  2052.     "TK_SIGNED",
  2053.     "TK_UNSIGNED",
  2054.     "TK_FLOAT",
  2055.     "TK_DOUBLE",
  2056.     "TK_CONST",
  2057.     "TK_VOLATILE",
  2058.     "TK_VOID",
  2059.     "TK_STRUCT",
  2060.     "TK_UNION",
  2061.     "TK_ENUM",
  2062.     "TK_ELIPSIS",
  2063.     "TK_RANGE",
  2064.     "TK_CASE",
  2065.     "TK_DEFAULT",
  2066.     "TK_IF",
  2067.     "TK_ELSE",
  2068.     "TK_SWITCH",
  2069.     "TK_WHILE",
  2070.     "TK_DO",
  2071.     "TK_FOR",
  2072.     "TK_GOTO",
  2073.     "TK_CONTINUE",
  2074.     "TK_BREAK",
  2075.     "TK_RETURN",
  2076.     "THEN",
  2077.     0
  2078. };
  2079. char * yysvar[] = {    "$accept",
  2080.     "translation_unit",
  2081.     "primary_expr",
  2082.     "identifier",
  2083.     "string_list",
  2084.     "expr",
  2085.     "postfix_expr",
  2086.     "argument_expr_list",
  2087.     "assignment_expr",
  2088.     "unary_expr",
  2089.     "unary_operator",
  2090.     "cast_expr",
  2091.     "type_name",
  2092.     "multiplicative_expr",
  2093.     "additive_expr",
  2094.     "shift_expr",
  2095.     "relational_expr",
  2096.     "equality_expr",
  2097.     "and_expr",
  2098.     "exclusive_or_expr",
  2099.     "inclusive_or_expr",
  2100.     "logical_and_expr",
  2101.     "logical_or_expr",
  2102.     "conditional_expr",
  2103.     "assignment_operator",
  2104.     "constant_expr",
  2105.     "declaration",
  2106.     "declaration_specifiers",
  2107.     "init_declarator_list",
  2108.     "storage_class_specifier",
  2109.     "$80",
  2110.     "type_specifier",
  2111.     "$83",
  2112.     "init_declarator",
  2113.     "declarator",
  2114.     "initializer",
  2115.     "struct_or_union_specifier",
  2116.     "enum_specifier",
  2117.     "struct_or_union",
  2118.     "$108",
  2119.     "struct_declaration_list",
  2120.     "$110",
  2121.     "struct_declaration",
  2122.     "type_specifier_list",
  2123.     "struct_declarator_list",
  2124.     "struct_declarator",
  2125.     "enum",
  2126.     "enumerator_list",
  2127.     "$124",
  2128.     "enumerator",
  2129.     "declarator2",
  2130.     "pointer",
  2131.     "$138",
  2132.     "$140",
  2133.     "parameter_type_list",
  2134.     "$141",
  2135.     "$143",
  2136.     "parameter_identifier_list",
  2137.     "$144",
  2138.     "identifier_list",
  2139.     "parameter_list",
  2140.     "parameter_declaration",
  2141.     "abstract_declarator",
  2142.     "direct_abstract_declarator",
  2143.     "initializer_list",
  2144.     "statement",
  2145.     "labeled_statement",
  2146.     "compound_statement",
  2147.     "expression_statement",
  2148.     "selection_statement",
  2149.     "iteration_statement",
  2150.     "jump_statement",
  2151.     "$188",
  2152.     "$190",
  2153.     "statement_list",
  2154.     "declaration_list",
  2155.     "$202",
  2156.     "$203",
  2157.     "opt_else",
  2158.     "$205",
  2159.     "$208",
  2160.     "$210",
  2161.     "$212",
  2162.     "$213",
  2163.     "opt_expr",
  2164.     "$215",
  2165.     "$217",
  2166.     "external_declaration",
  2167.     "function_definition",
  2168.     "$229",
  2169.     "function_body",
  2170.     "$231",
  2171.     0
  2172. };
  2173. short yyrmap[] = {
  2174.      236,  237,  238,   80,   83,  108,  112,  124,  126,  138, 
  2175.      140,  143,  231,  235,  229,  227,  218,  217,  216,  215, 
  2176.      214,  213,  212,  211,  210,  209,  208,  206,  205,  203, 
  2177.      202,  190,  188,  187,  186,  185,  184,  183,  182,  144, 
  2178.      141,  134,  127,  123,  114,  113,  110,   89,   84,   81, 
  2179.       78,   77,   60,    1,    2,    4,    5,    6,    7,    8, 
  2180.        9,   10,   11,   12,   13,   14,   15,   16,   18,   19, 
  2181.       20,   21,   22,   23,   24,   25,   26,   27,   28,   29, 
  2182.       30,   31,   32,   33,   34,   61,   62,   63,   64,   65, 
  2183.       66,   67,   68,   69,   70,   71,   72,   73,   74,   75, 
  2184.       76,   85,   86,   88,   90,   91,   92,   93,   94,   95, 
  2185.       96,   97,   98,   99,  100,  101,  102,  103,  104,  105, 
  2186.      106,  107,  109,  111,  115,  116,  117,  118,  119,  121, 
  2187.      122,  125,  128,  129,  131,  135,  136,  137,  139,  142, 
  2188.      145,  148,  149,  150,  151,  153,  154,  155,  157,  158, 
  2189.      159,  160,  161,  163,  167,  168,  169,  170,  171,  172, 
  2190.      173,  174,  175,  176,  177,  178,  179,  180,  181,  189, 
  2191.      191,  192,  193,  194,  195,  196,  197,  198,  199,  200, 
  2192.      201,  204,  221,  222,  223,  224,  225,  226,  228,  230, 
  2193.      232,  233,  234,  220,  219,  207,  166,  165,  164,  162, 
  2194.      156,  152,  147,  146,  133,  132,  130,  120,   87,   82, 
  2195.       79,   59,   58,   57,   56,   55,   54,   53,   52,   51, 
  2196.       50,   49,   48,   47,   46,   45,   44,   43,   42,   41, 
  2197.       40,   39,   38,   37,   36,   35,   17,    3,    0
  2198. };
  2199. short yysmap[] = {
  2200.        6,   10,   35,   36,   38,   42,   44,   45,   47,   50, 
  2201.       53,   73,   74,   75,   76,   77,   78,   79,   80,   81, 
  2202.       82,   95,   99,  103,  116,  141,  142,  143,  145,  149, 
  2203.      150,  185,  203,  207,  237,  241,  244,  245,  246,  247, 
  2204.      248,  249,  250,  251,  252,  253,  254,  255,  256,  257, 
  2205.      258,  270,  277,  310,  346,  356,  364,  373,  371,  367, 
  2206.      365,  363,  362,  357,  355,  351,  350,  349,  348,  347, 
  2207.      336,  334,  332,  327,  326,  324,  321,  320,  314,  312, 
  2208.      309,  307,  306,  305,  303,  293,  291,  290,  289,  287, 
  2209.      284,  282,  279,  276,  273,  271,  269,  268,  266,  262, 
  2210.      243,  242,  240,  236,  235,  234,  233,  232,  231,  219, 
  2211.      217,  212,  211,  210,  209,  208,  206,  202,  198,  196, 
  2212.      195,  193,  191,  190,  189,  187,  186,  184,  183,  182, 
  2213.      181,  177,  174,  172,  171,  170,  169,  168,  167,  166, 
  2214.      165,  164,  163,  162,  161,  160,  159,  158,  157,  156, 
  2215.      155,  154,  138,  131,  130,  128,  127,  124,  123,  122, 
  2216.      120,  119,  118,  117,  112,  111,  110,  107,  106,  105, 
  2217.      102,   98,   94,   93,   92,   91,   70,   69,   68,   67, 
  2218.       63,   62,   60,   55,   52,   51,   48,   46,   43,   39, 
  2219.       37,   15,   12,    9,    7,    0,    1,    2,    4,  374, 
  2220.      366,  370,  361,  372,  288,  121,  358,  328,  375,  368, 
  2221.      359,  329,  360,  330,  216,  294,  297,  132,  133,  134, 
  2222.      135,  136,  146,  151,    8,   11,  192,   13,   14,   49, 
  2223.       34,  108,  109,  113,   56,  340,  101,  100,  272,   97, 
  2224.      188,   96,  316,  267,  315,  264,  263,  180,  179,  265, 
  2225.      341,  178,  176,  175,  173,  313,   90,   89,   88,   87, 
  2226.       86,   85,   84,  317,   83,  261,  260,  259,  140,  296, 
  2227.      230,  229,  228,  227,  226,  225,  224,  223,  222,  221, 
  2228.      220,  139,  295,   72,   54,  201,  200,   33,   32,   31, 
  2229.       30,   29,   28,   27,   26,   25,   24,   23,   22,   21, 
  2230.       20,   19,   18,   17,   16,  323,  281,  194,  280,  322, 
  2231.      278,  343,  319,  342,  318,  104,  275,  274,   66,   71, 
  2232.      153,  152,  311,  300,   41,   65,   40,   64,  299,  144, 
  2233.      298,  302,  148,  301,  239,  147,  238,  339,  304,  333, 
  2234.      337,  354,  308,  338,  335,  353,  199,  325,  345,  283, 
  2235.      344,  137,  352,  331,  129,  215,  213,  292,   61,  115, 
  2236.      126,  214,  125,  218,  369,  286,  205,  204,  285,    5, 
  2237.       57,    3,   59,  197,   58,  114
  2238. };
  2239. int yyntoken = 86;
  2240. int yynvar = 92;
  2241. int yynstate = 376;
  2242. int yynrule = 239;
  2243. #endif
  2244.